package com.paul.sys.tools.dbutil.dialect;

public class OracleDialect extends Dialect {

    /*
     * (non-Javadoc)
     * @see
     * org.mybatis.extend.interceptor.IDialect#getLimitString(java.lang.String,
     * int, int)
     */
    @Override
    public String getLimitString(String sql, int offset, int limit)
    {

        sql = sql.trim();
        StringBuilder pagingSelect = new StringBuilder(sql.length() + 100);

        pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
        pagingSelect.append(sql);
        pagingSelect.append(" ) row_ where rownum <= ").append(offset + limit)
        			.append(" ) where rownum_ > ").append(offset);

        return pagingSelect.toString();
    }
}
